package com.surelution.projects.crm
import org.codehaus.groovy.grails.commons.ConfigurationHolder


class PictureController {
	def pictureService
	
    def index = { }
	def marketPicture = {
		def marketPicture = MarketPicture.get(params.id)
		def picture = marketPicture.picture
		def filePath = pictureService.loadPicture(picture)
		
		FileInputStream fos = new FileInputStream(filePath)
		response.contentType = "image/${picture.type}"
		response.outputStream << fos
		response.outputStream.flush()
		fos.close()
		return
	}

	def competitorCompany = {
		def marketPicture = CompetitorCompany.get(params.id)
		def picture = marketPicture.logoIcon
		def filePath = pictureService.loadPicture(picture)
		
		FileInputStream fos = new FileInputStream(filePath)
		response.contentType = "image/${picture.type}"
		response.outputStream << fos
		response.outputStream.flush()
		fos.close()
		return
	}

	def ownStationPic = {
		def stationPicture = StationPicture.get(params.id)
		def picture = stationPicture.picture
		def filePath = pictureService.loadPicture(picture)
		
		FileInputStream fos = new FileInputStream(filePath)
		response.contentType = "image/${picture.type}"
		response.outputStream << fos
		response.outputStream.flush()
		fos.close()
		return
	}

	def competitorStationPic = {
		def stationPicture = StationPicture.get(params.id)
		def picture = stationPicture.picture
		def filePath = pictureService.loadPicture(picture)
		
		FileInputStream fos = new FileInputStream(filePath)
		response.contentType = "image/${picture.type}"
		response.outputStream << fos
		response.outputStream.flush()
		fos.close()
		return
	}
}
